package StudyCode.summary.textfile;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.NoSuchElementException;
import java.util.Scanner;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadsTextFile {
	private static Scanner input;

	public static void main(String[] args) {
		openFile();
		readRecords();
		closeFile();
	}

	public static void openFile() {
		try {
			input = new Scanner(Paths.get("E:/Copy/test1.txt"));
		} catch (IOException ioException) {
			ioException.printStackTrace();
			System.exit(1);
		}
	}

	public static void readRecords() {

		try {
			while (input.hasNext()) {
				System.out.println(input.next());
			}
		} catch (NoSuchElementException elementException) {
			elementException.printStackTrace();
		} catch (IllegalStateException stateException) {
			stateException.printStackTrace();
		}
	}

	private static void closeFile() {
		if (input != null)
			input.close();
	}
}
